import {createStore,applyMiddleware} from 'redux';
import {routerMiddleware} from 'connected-react-router'
import logger from 'redux-logger';
import promise from 'redux-promise';
import thunk from 'redux-thunk';
import reducers from './reducers'
import history from './history'
import { persistStore, persistReducer } from 'redux-persist'// 持久化
import storage from 'redux-persist/lib/storage' // defaults to localStorage for web
 
const persistConfig = {
  key: 'root',
  storage,
  whitelist:[], // 要存入storage白名单,如：home
}

const persistedReducer = persistReducer(persistConfig, reducers)
 
// let store=createStore(persistedReducer,applyMiddleware(logger,thunk,promise,routerMiddleware(history)));
let store=createStore(persistedReducer,applyMiddleware(thunk,promise,routerMiddleware(history)));

let persistor = persistStore(store);

window.store=store;

export {
    store,
    persistor,
};


